Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Printing /
Chapter 2 - Core Printing Features / Using Core Printing Features


Displaying QuickDraw GX Print Dialog Boxes

You call functions to display most QuickDraw GX print dialog boxes.You use the GXJobDefaultFormatDialog function to display the Page Setup dialog box, and you use the GXJobPrintDialog function to display the Print dialog box. You use the GXFormatDialog function to display the Custom Page Setup dialog box, which is discussed in the chapter "Page Formatting and Dialog Box Customization" in this book.

Displaying the Page Setup Dialog Box

When the user chooses the Page Setup menu command from the File menu, you call the GXJobDefaultFormatDialog function to display the Page Setup dialog box. In this dialog box, the user can specify formatting information for the default format. For example, the user can specify the paper type, orientation, and scaling.

QuickDraw GX stores a user's responses to some dialog items in the Page Setup dialog box in a format collection. QuickDraw GX stores default items, such as these, for you automatically. The format collection is discussed in the chapter "Page Formatting and Dialog Box Customization" in this book.

Figure 2-5 shows the Page Setup dialog box the user sees when you call the GXJobDefaultFormatDialog function.

Figure 2-5 The Page Setup dialog box

If the user chooses More Choices in the Page Setup dialog box, QuickDraw GX expands the dialog box. Figure 2-6 shows the expanded Page Setup dialog box. The expanded dialog box in this figure only contains one panel, the General panel. A printer driver, printing extension, or application can customize the dialog box to add additional panels. For more information about adding panels, see the chapter "Page Formatting and Dialog Box Customization" in this book.

Figure 2-6 The expanded Page Setup dialog box

Listing 2-14 shows the MyFormatDialog function, which calls the GXJobDefaultFormatDialog function to display the Page Setup dialog box. The Edit menu structure, gxEditMenuRecord, is set up before the dialog box is displayed. For information about the Edit menu structure, see "Edit Menu Structure" beginning on page 2-9. If the user chooses the Format button and there are no errors, document formatting can proceed.

Listing 2-14 Displaying the Page Setup dialog box

#define mEdit     128

#define kUndo     1
#define kCut      3
#define kCopy     4
#define kPaste    5
#define kClear    6
...
OSErr MyFormatDialog(MyDocumentPtr myDocument)
{
   OSErr             err;
   gxDialogResult    result;
   gxEditMenuRecord  editMenuRec;

/* Fill in the location of your application's Edit menu items. */

   editMenuRec.editMenuID  = mEdit;
   editMenuRec.cutItem     = kCut; 
   editMenuRec.copyItem    = kCopy;
   editMenuRec.pasteItem   = kPaste;
   editMenuRec.clearItem   = kClear;
   editMenuRec.undoItem    = kUndo;
   
/* Display the Page Setup dialog box. */
   result = GXJobDefaultFormatDialog(myDocument->documentJob, 
                                    &editMenuRec);
   err = GXGetJobError(myDocument->documentJob);
   
/* 
   If the user chooses the Format button and there are no 
   errors, perform document formatting.
*/
   if ((err == noErr) && (result == gxOKSelected))
   {
      /* 
         Place your application-specific code here if you need
         to repaginate the document.
      */
      ...
   }
   
   return err;
}

Displaying the Print Dialog Box

When the user chooses the Print menu command from the File menu, you call the GXJobPrintDialog function to display the Print dialog box. In this dialog box, the user can specify information related to actual printing of the document. For example, in the panels of the Print dialog box the user can specify the printer, print quality, number of copies to print, page range, automatic or manual paper feed, and whether a document should be sent to a printer or a file.

QuickDraw GX stores a user's responses to some dialog items in the Print dialog box in a job collection. The job collection is discussed in the chapter "Page Formatting and Dialog Box Customization" in this book.

Figure 2-7 shows the Print dialog box the user sees when you call the GXJobPrintDialog function.

Figure 2-7 The Print dialog box

If the user chooses More Choices in the Print dialog box, QuickDraw GX expands the dialog box. Figure 2-8 shows the expanded Print dialog box. The expanded dialog box includes the standard panels (General, Print Time, and Paper Match), and any panels added by the application, printing extensions, or a printer driver.

Figure 2-8 The expanded Print dialog box

Listing 2-15 shows the MyPrintDialog function, which calls the GXJobPrintDialog function to display the Print dialog box. The Edit menu structure, gxEditMenuRecord, is set up before the dialog box is displayed. For information about the Edit menu structure, see "Edit Menu Structure" beginning on page 2-9. If the user chooses the Print button and there are no errors, printing can proceed.

Listing 2-15 Displaying the Print dialog box

OSErr MyPrintDialog(MyDocumentPtr myDocument)
{
   OSErr             err;
   gxDialogResult    result;
   gxEditMenuRecord  editMenuRec;

/* Fill in the location of your application's Edit menu items. */

   editMenuRec.editMenuID  = mEdit;
   editMenuRec.cutItem     = kCut; 
   editMenuRec.copyItem    = kCopy;
   editMenuRec.pasteItem   = kPaste;
   editMenuRec.clearItem   = kClear
   editMenuRec.undoItem    = kUndo;
   
/* Display the Print dialog box. */
   result = GXJobPrintDialog(myDocument->documentJob,
                            &editMenuRec);
   err = GXGetJobError(myDocument->documentJob);
   
/* 
   If the user chooses the Print button and there are no errors, 
   call your printing function to print the pages.
*/
   if ((err == noErr) && (result == gxOKSelected))
      err = MyPrintDocument(myDocument);
   
   return err;
}

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help